package com.zy.qudadid.ui.activity;

import android.os.Bundle;
import android.widget.EditText;

import com.rey.material.widget.Button;
import com.zy.lcpassenger.R;
import com.zy.qudadid.presenter.RegisterCPwdPresenter;
import com.zy.qudadid.ui.activity.base.ToolBarActivity;
import com.zy.qudadid.ui.view.RegisterCPwdView;
import com.zy.qudadid.utils.ActivityUtil;
import com.zy.qudadid.utils.Bun;
import com.zy.qudadid.utils.StringUtil;


import butterknife.Bind;
import butterknife.OnClick;

/**
 * Created by ninos on 2016/7/30.
 */
public class RegisterCPwdActivity extends ToolBarActivity<RegisterCPwdPresenter> implements RegisterCPwdView {

    @Bind(R.id.l_login)Button l_login;
    @Bind(R.id.rcp_pwd)EditText rcp_pwd;
    @Bind(R.id.rcp_repwd)EditText rcp_repwd;
    private String phoneNumber;
    private String id;
    private String pwd;
    private String lng="";
    private String lat="";
    @OnClick(R.id.l_login)
    public void l_login(){
        if(rcp_pwd.getText().toString().trim().equals("")||rcp_repwd.getText().toString().trim().equals("")){
            toast("请填入密码后点击下一步");
            return;
        }
        if(!StringUtil.isPassword(rcp_pwd.getText().toString().trim())||!StringUtil.isPassword(rcp_repwd.getText().toString().trim())){
            toast("请确保密码由6-16位数字和字母组成");
            return;
        }
        if(!rcp_pwd.getText().toString().trim().equals(rcp_repwd.getText().toString().trim())){
            toast("密码两次输入不一致");
            return;
        }
        pwd = rcp_pwd.getText().toString().trim();
        toast("密码设置成功");
        ActivityUtil.addActivity(this);
        startActivity(RegisterCInfoActivity.class,new Bun().putString("phoneNumber",phoneNumber).putString("pwd",pwd).putString("lat",lat).putString("lng",lng).ok());

    }


    @Override
    protected CharSequence provideTitle() {
        return "填写密码";
    }

    @Override
    protected int provideContentViewId() {
        return R.layout.activity_register_c_pwd;
    }

    @Override
    protected void initThings(Bundle savedInstanceState) {
        super.initThings(savedInstanceState);
        phoneNumber = getIntent().getBundleExtra("data").getString("phoneNumber");
        lat = getIntent().getBundleExtra("data").getString("lat");
        lng = getIntent().getBundleExtra("data").getString("lng");
    }

    @Override
    public void initListeners() {

    }

    @Override
    public RegisterCPwdPresenter createPresenter() {
        return new RegisterCPwdPresenter();
    }
}
